package br.com.sistemasaude.dao;

import javax.persistence.EntityManager;

import br.com.sistemasaude.bean.RelMedAgend;
import br.com.sistemasaude.util.JpaUtil;

public class AlocamentoDAOImpl implements AlocamentoDAO{

	private final GenericDAO<RelMedAgend> dao;	
	EntityManager em = new JpaUtil().getEntityManager();
	
	public AlocamentoDAOImpl() {
		dao = new GenericDAO<RelMedAgend>(em, RelMedAgend.class);
		}
	
	public void salvar(RelMedAgend alocacao){
		
		try {

			em.getTransaction().begin();
			dao.salvar(alocacao);
			em.getTransaction().commit();

		} catch (Exception e) {
			
			em.getTransaction().rollback();
			e.printStackTrace();
			
		} finally {
			em.close();
		}
		
	}
	
}
